-- Copyright (c) 2024-present Trajectronix Open Source Group
set_xmakever("2.6.9")
set_project("cppfastbox")
set_version("0.0.1", {build = "%Y%m%d%H%M"})
set_allowedmodes("debug", "release", "minsizerel", "releasedbg")
set_warnings("allextra")
set_languages("cxxlatest")
includes("configure/*.lua", "*/xmake.lua")
add_options("march", "mtune", "coroutines")
set_policy("build.warning", true)
add_includedirs("third-party/fast_io/include")

rule("debug")
    on_load(function (target)
        target:set("symbols", "debug")
        target:set("optimize", "none")
        target:add("defines", "DEBUG", "_DEBUG")
    end)
rule_end()
rule("release")
    on_load(function (target)
        target:add("defines", "NDEBUG")
        target:set("optimize", "aggressive")
        target:set("strip", "all")
        target:set("policy", "build.optimization.lto", true)
    end)
rule_end()
rule("minsizerel")
    on_load(function (target)
        target:add("defines", "NDEBUG")
        target:set("optimize", "smallest")
        target:set("strip", "all")
        target:set("policy", "build.optimization.lto", true)
    end)
rule_end()
rule("releasedbg")
    on_load(function (target)
        target:set("optimize", "aggressive")
        target:set("symbols", "debug")
        target:set("policy", "build.optimization.lto", true)
    end)
rule_end()
add_rules(get_config("mode"))

target("libc")
    add_deps("libc-header", "libc-lib")
    set_kind("phony")
target_end()
